<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>删除商品</title>
    <meta name="keywords" content="知果汇"/>
    <meta name="description" content="知果汇"/>
    <link rel="SHORTCUT ICON" href="images/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="_CSS_/reset.css">
    <link rel="stylesheet" type="text/css" href="_CSS_/common.css">
    <link rel="stylesheet" type="text/css" href="_CSS_/store_center.css"/>
    <style type="text/css">
        html, body {
            width: 570px;
            min-width: 570px;
        }

        form {
            width: 540px;
            padding: 20px;
        }

        .formItem {
            overflow: hidden;
        }

        .formItem label {
            font-size: 14px;
            color: #333333;
        }

        .products {
            overflow: hidden;
            width: 470px;
        }

        .products img {
            width: 120px;
            height: 120px;
            float: left;
        }

        .products p {
            width: 340px;
            display: inline-block;
            float: left;
            padding-left: 10px;
            margin-bottom: 15px;
        }

        .productName {
            font-size: 14px;
            color: #333333;
        }

        .greyTag {
            color: #999999;
            font-size: 12px;
            width: 70px;
            display: inline-block;
        }

        .types, .mode {
            font-size: 11px;
            color: #333333;
        }

        .priceNum {
            font-size: 14px;
            color: #FF4900;
        }

        .fillin {
            border: 1px solid #E5E5E5;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            color: #999999;
            width: 428px;
            padding: 0 10px;
        }

        .commentsFill {
            font-size: 14px;
            text-indent: 0;
        }

        .btn-box {
            width: 570px;
            text-align: center;
            margin-top: 20px;
        }

        .btn-box a {
            display: inline-block;
            height: 37px;
            line-height: 37px;
            margin: 5px 25px 0;
            padding: 0 30px;
            border: 1px solid #dedede;
            background-color: #fff;
            color: #333;
            border-radius: 5px;
            font-weight: 400;
            cursor: pointer;
            text-decoration: none;
            font-size: 14px;
        }

        .btn-box .btn-n1 {
            border-color: #3377c0;
            background-color: #3377c0;
            color: #ffffff;
        }

        .con-p {
            font-size: 16px;
            color: #333333;
        }

        .con-pl {
            font-size: 14px;
        }
    </style>
</head>
<body>
<form action="" method="post">
    <div class="formItem">
        <div class="products fl" name="products">
            <img class="name" src="" alt=""/>
            <p class="productName name"></p>
            <p class="prices name"></p>
            <!-- 注意：交易类和服务类不同 -->
            <p class="mode"><span class="greyTag">交易方式</span><span class="serviceType name"></span></p>
            <p class="types"><span class="greyTag">类型</span><span class="productType name"></span></p>
        </div>
    </div>
    <input type="hidden" id="id">
    <input type="hidden" id="num">
    <input type="hidden" id="page">
    <p class="con-p con-pl">确定要删除该商品吗？</p>
    <div class="btn-box">
        <a class="btn-n1" href="#" title="确认" onclick="confirm()">确认</a>
        <a class="btn-n2" href="#" title="取消" onclick="cancel()">取消</a>
    </div>
</form>
</body>
<script src="_JS_/jquery-1.8.3.min.js"></script>
<script src="_JS_/jquery.base64.js"></script>
<script src="_JS_/jquery.cookie.js"></script>
<script src="_JS_/common.js"></script>
<script src="_P_/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        var url = window.location.href;
        id = url.split("#")[1];
        page_id = url.split("#")[2];
        num = url.split("#")[3];
        $("#id").val(id);
        $("#page").val(page_id);
        $("#num").val(num);

        $.ajax({
            type: "get",
            url: "{:url('api/shop/all_goods')}",
            data: {id: id, 'num': num},
            dataType: 'jsonp',
            success: function (msg) {
                if (msg.code == 200) {
                    if (num == 0) {
                        $(".name").eq(0).attr('src', "/Images/tradingMarket/" + msg.data.image);
                        $(".name").eq(1).text(msg.data.username);
                        $(".name").eq(2).text("￥" + msg.data.store + "起");
                        $(".name").eq(3).text(msg.data.market_name);
                        $(".name").eq(4).text('交易类商品');
                    } else {
                        $(".name").eq(0).attr('src', "/Images/tradingMarket/" + msg.data.pic);
                        $(".name").eq(1).text(msg.data.goods_name);
                        $(".name").eq(2).text("￥" + msg.data.price + "起");
                        $(".name").eq(3).text(msg.data.t_name);
                        $(".name").eq(4).text('服务类商品');
                    }
                } else {
                    layer.msg(msg.message, {icon: 5, time: 5000});
                }
            }

        });
    });

    //确认
    function confirm() {
        var id = $("#id").val();
        var num = $("#num").val();
        var page_id = $("#page").val();
        $.ajax({
            type: "get",
            url: "{:url('api/shop/del_goods')}",
            data: {id: id, 'num': num},
            dataType: 'jsonp',
			beforeSend: function () {
                var index = layer.load(1, {
                    shade: [0.1, '#333333'] //0.1透明度的白色背景
                });
			},
            success: function (msg) {
                layer.closeAll();
                if (msg.code == 200) {
                    var userinfo = $.cookie('userinfo');
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.postfile(page_id, userinfo, num);
                    parent.layer.close(index);
                } else {
                    layer.msg(msg.message, {icon: 5, time: 5000});
                }
            }

        });


    }

    //取消
    function cancel(obj) {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</html>
